package com.example.springbootdeom.contrlloer;

import com.example.springbootdeom.entity.*;
import com.example.springbootdeom.service.TeacherService;
import com.example.springbootdeom.serviceImpl.TeacherServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;



@RestController
public class TeacherController {

    @Autowired
    TeacherService teacherServiceimpl;
    @GetMapping("tests.action")
    public String Test(){
        return "hahhaha";
    }


    //查询个人信息(id)
    @PostMapping("getTeacher.action")
    public Teacher getTeacher(int id){
        Teacher teacher =teacherServiceimpl.getTeacher(id);
        return teacher;
    }

    @GetMapping("getTeacherClass.acction")
    //查询所上课班级(传入的值是教师id)
    public List<Classs> getClasss(Integer id){
        System.out.println(id);
        return teacherServiceimpl.getClasss(id);
    }

    //查询班级全部成绩(传入的值是班级号和课程号)
    @PostMapping("getStudentClass.action")
    public List<ClassGrade> getStudent(Integer classId, Integer courseId){
        List<ClassGrade> list=teacherServiceimpl.getStudentClass(classId,courseId);
        return list;
    }
    //根据班级号课程号来查询课程成绩()
    @PostMapping("getResult.action")
    public List<Result> getResult(int rId,int cId){
        System.out.println(rId+cId);
        return teacherServiceimpl.getResult(rId,cId);
    }
    //修改成绩
    @PostMapping("modifyResult.action")
    public String modifyResult(double result, int stuId, int curId){
        if(teacherServiceimpl.modifyResult(result,stuId,curId))
        {
            return "ok";
        }

        return "error";
    }
    //查询教师的任课课程
    @PostMapping("getTeacherCourse.action")
    public List<TeacherCourse> getTeacherCourse(int id){
        return teacherServiceimpl.getTeacherCourse(id);
    }
    //添加班级方法（将老师加入到某班级）
    
    public void  addClassTeacher(){

    }

    //获取全班信息（传入班级id）
    @PostMapping("getClassAllStudent.action")
    public List<Student> getClassAllStudent(int id){
        return teacherServiceimpl.getClassAllStudent(id);
    }

    //查询成绩不及格的人员名单
    @PostMapping("getFailAllStudent.action")
    public List<Result> getFailAllStudent(Integer classId, Integer courseId){
        return teacherServiceimpl.getFailAllStudent(classId,courseId);
    }
}
